#include "HashTable.h"
#include "HashBucket.h"
void test1()
{
	HashTable<int, int> h1;
	int a[] = { 1,4,24,34,7,44,17,37 };
	for (auto e : a)
	{
		h1.Insert(make_pair(e, e));
	}

	for (auto e : a)
	{
		auto ret = h1.Find(e);
		if (ret)
		{
			cout << e << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
	cout << endl;

	h1.Erase(34);
	h1.Erase(4);

	for (auto e : a)
	{
		auto ret = h1.Find(e);
		if (ret)
		{
			cout << ret->_kv.first << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
	cout << endl;

	HashTable<string, string> h2;
	string s[] = { "sort","apple","one" };
	for (auto e : s)
	{
		h2.Insert(make_pair(e, e));
	}
	for (auto e : s)
	{
		auto ret = h2.Find(e);
		if (ret)
		{
			cout << e << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
}
void test2()
{
	HashBucket<int, int> h1;
	int a[] = { 1,4,24,34,7,44,17,37 };
	for (auto e : a)
	{
		h1.Insert(make_pair(e, e));
	}

	for (auto e : a)
	{
		auto ret = h1.Find(e);
		if (ret)
		{
			cout << e << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
	cout << endl;

	h1.Erase(24);
	h1.Erase(17);
	h1.Erase(7);
	h1.Erase(1);

	for (auto e : a)
	{
		auto ret = h1.Find(e);
		if (ret)
		{
			cout << ret->_kv.first << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
	cout << endl;

	HashBucket<string, string> h2;
	string s[] = { "sort","apple","one","two","kkkk"};
	for (auto e : s)
	{
		h2.Insert(make_pair(e, e));
	}
	for (auto e : s)
	{
		auto ret = h2.Find(e);
		if (ret)
		{
			cout << e << ":E" << endl;
		}
		else
		{
			cout << e << ":D" << endl;
		}
	}
}
int main()
{
	//test1();
	test2();
	return 0;
}